package com.kensure.shike.collect.service;

import co.kensure.frame.JSBaseService;
import co.kensure.mem.MapUtils;
import co.kensure.mem.PageInfo;
import com.kensure.basekey.BaseKeyService;
import com.kensure.shike.collect.dao.SKCollectDao;
import com.kensure.shike.collect.model.SkCollect;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class SkCollectService extends JSBaseService {

    @Resource
    private BaseKeyService baseKeyService;

    @Resource
    private SKCollectDao dao;

    public boolean insert(SkCollect obj) {
        super.beforeInsert(obj);
        obj.setId(baseKeyService.getKey("sk_cms"));
        return dao.insert(obj);
    }

    public List<SkCollect> selectByWhere(Map<String, Object> parameters) {
        return dao.selectByWhere(parameters);
    }

    public long selectCountByWhere(Map<String, Object> parameters) {
        return dao.selectCountByWhere(parameters);
    }

    public void add(SkCollect obj) {
        insert(obj);
    }

    public List<SkCollect> selectByWhere(PageInfo page) {
        Map<String, Object> parameters = MapUtils.genMap("orderby", "id");
        MapUtils.putPageInfo(parameters, page);

        return selectByWhere(parameters);
    }

    public SkCollect detail(Long id) {
        return dao.selectOne(id);
    }

    public boolean delete(Long id) {
        return dao.delete(id);
    }
}
